#include "Common.fx"

//--------------------------------------
struct a2v {
	float4 pos		: POSITION;
	float3 normal	: NORMAL;
	float4 color	: COLOR0;
	float2 uv		: TEXCOORD0;
};

struct v2f {
	float4 pos		: POSITION;
	float4 color	: COLOR0;
	float2 uv		: TEXCOORD0;
	float3 normal	: TEXCOORD1;
};

//--------------------------------------
v2f vsMain(a2v input) {
	
	v2f output;
	
	output.pos = mul(g_WorldViewProjMtx, input.pos);
	output.pos.z *= output.pos.w;
	
	output.uv = input.uv;
	output.normal = input.normal;
	output.color = input.color;
	
	return output;
}

//--------------------------------------
f2fb psMain(v2f input) {

	f2fb output;
	
	float3 n = normalize(input.normal);
	float3 l = normalize( float3(0, 1, -1) );
	
	//output.c0 = lerp(
	//	float4(0.25, 0.5, 0.25, 1.0),
	//	float4(0.5, 0.8, 0.5, 1.0),
	//	saturate( dot(n, l) ) );
	
	output.c0 = (saturate( dot(n, l) ) * 0.6 + 0.4) * input.color;
	
	return output;
}

//--------------------------------------
technique Visualization {

	pass {
	
		AlphaBlendEnable	= false;
		AlphaTestEnable		= false;
		
		VertexShader		= compile vs_3_0 vsMain();
		PixelShader			= compile ps_3_0 psMain();
	}
}

//--------------------------------------